import { request } from 'umi';
import { createCRUD } from '@/utils/api';

const route = '/ide_image';

const crud = createCRUD<ImageEntity>(route);

export { crud };

export async function getImage(id: string) {
  return await request<ImageEntity>(`${route}/get_entity?id=${id}`, {
    method: 'GET',
  });
}

export async function getImageOptions(registry_id: string) {
  return await request<[]>(`${route}/get_ide_image_options?registry_id=${registry_id}`, {
    method: 'GET',
  });
}

export async function getBuildLog(id: string) {
  return await request(`${route}/show_logs?id=${id}`, {
    method: 'GET',
  });
}

export async function buildImage(id: string) {
  return await request<ImageEntity>(`${route}/build?id=${id}`, {
    method: 'GET',
  });
}
